package com.xxxxxx.servlet;

import java.io.IOException;

import java.io.PrintWriter;

import jakarta.servlet.ServletException;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

/*
 * 响应数据
 * 		getWriter()   		 字符输出流(输出字符串)
 * 		getOutputStream 	 字节输出流(输出一切数据)
 * 		两种流不可同时使用,如果同时使用会报错
 */		

@WebServlet("/S1")
public class Servlet01 extends HttpServlet {

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
			//getWriter() 字符输出流 (输出字符串)
			//获取字符输出流
	/*	PrintWriter writer = response.getWriter();
			//输出数据
		writer.write("Hello");
	*/
		
		/*getOutputStream()  字节输出流 (输出一切数据)*/
		//得到字节输出流
		ServletOutputStream out = response.getOutputStream();
		//输出数据
		out.write("Hi".getBytes());
		
	}
		
}
